package com.hzncc.flowable_diboot.flowable.servicetask.payment;

import com.diboot.core.util.ContextHolder;
import com.hzncc.flowable_diboot.payment.service.PaymentContractService;
import com.hzncc.flowable_diboot.payment.service.impl.PaymentContractServiceImpl;
import com.sap.conn.jco.JCoException;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.JavaDelegate;
import org.springframework.stereotype.Service;

@Service
public class CancelPaymentRegister implements JavaDelegate {


    @Override
    public void execute(DelegateExecution execution) {

        PaymentContractService paymentContractService = ContextHolder.getBean(PaymentContractServiceImpl.class);

        String paymentRegisterId = (String) execution.getVariable("paymentRegisterId");
        try {
            paymentContractService.revokePaymentRegister(paymentRegisterId);
        } catch (JCoException e) {
            throw new RuntimeException(e);
        }
    }
}
